package com.da.springtest.ioc.xml;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author chenlida
 * @date 2020/6/13 20:59
 * @description
 */
public class HelloWorld {
    public void say() {
        System.out.println("hello,一起学spring!");
    }

    public static void main(String[] args) {
        //1.bean配置文件位置
        String beanXml = "classpath:bean/beanXml.xml";

        //2.创建ClassPathXmlApplicationContext容器，给容器指定需要加载的bean配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(beanXml);

        //3.从容器中获取需要的bean
        HelloWorld helloWorld = context.getBean("helloWorld", HelloWorld.class);

        //4.使用对象
        helloWorld.say();
    }
}
